<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>团课排课</title>
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<link rel="stylesheet" href="css/vant.css">
	<link rel="stylesheet" href="css/homePage.css">
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/flexible.css">
	<script src="js/vue/vue.js"></script>
	<script src="js/vue/axios.js"></script>
	<script src="js//vue/vant.js"></script>
	<script src="js/jquery.md5.js"></script>
	<script src="js/vue/qs.js"></script>
	<script src="js/glabe.js"></script>
	<script src="js/jquery-3.3.1.min.js"></script>
	<script src="js/flexible.js"></script>
	<style>
		.timeType input:disabled {
			opacity:1; 
			-webkit-text-fill-color:rgba(0,0,0,0.6); 
			-webkit-opacity: 1;
			background: #fff;
			color: rgba(0,0,0,0.6);
		}
	</style>
</head>
<body class="background_color">
	<div id="app">
		<template>
			<div class="customer_type box_show">
				<p class="private_title">课程信息</p>
				<form action="" method="">
					<table class="customer_type_table">
						<tbody>
							<tr class="clearfix" @click="classShow = true">
								<td><span>课程名称</span></td>
								<td>
									<span style="margin-right: 0.1rem;">{{classVal ? classVal.Title : '请选择课程名称'}}</span>
									<img src="images/right_icon.png" alt="">
								</td>	
							</tr>	
							<van-popup v-model="classShow" position="bottom">
								<van-picker
								show-toolbar
								:columns="classList"
								@cancel="classShow = false"
								@confirm="classYes"
								value-key="Title"
								/>
							</van-popup>
							<tr class="clearfix" @click="jlShow = true">
								<td><span>教练</span></td>
								<td>
									<span style="margin-right: 0.1rem;">{{jlVal ? jlVal.Sname : '请选择教练'}}</span>
									<img src="images/right_icon.png" alt="">
								</td>
							</tr>	
							<van-popup v-model="jlShow" position="bottom">
								<van-picker
								show-toolbar
								:columns="jlList"
								@cancel="jlShow = false"
								@confirm="jlYes"
								value-key="Sname"
								/>
							</van-popup>
							<tr class="clearfix" @click="siteShow = true">
								<td><span>场地</span></td>
								<td>
									<span style="margin-right: 0.1rem;">{{siteVal ? siteVal.Space_name : '请选择场地'}}</span>
									<img src="images/right_icon.png" alt="">
								</td>
							</tr>
							<van-popup v-model="siteShow" position="bottom">
								<van-picker
								show-toolbar
								:columns="siteList"
								@cancel="siteShow = false"
								@confirm="siteYes"
								value-key="Space_name"
								/>
							</van-popup>
							<tr class="clearfix">
								<td><span>预约</span></td>
								<td>
									<div class="rf sex">
										<label @click="bespeakClick(0)">
											<input type=radio name=x1 :checked="IsBespeak == 0 ? 'checked' : ''"><span>需要</span>
										</label>
										<label @click="bespeakClick(1)">
											<input type=radio name=x1 :checked="IsBespeak == 1 ? 'checked' : ''"><span>不需要</span>
										</label>
									</div>
								</td>
							</tr>
							<tr class="clearfix">
								<td><span>会员签到</span></td>
								<td>
									<div class="rf sex padding14">
										<label @click="signClick(0)">
											<input type=radio name=x2 :checked="IsSign == 0 ? 'checked' : ''"><span>允许</span>
										</label>
										<label @click="signClick(1)">
											<input type=radio name=x2 :checked="IsSign == 1 ? 'checked' : ''"><span>不允许</span>
										</label>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
				</form>
			</div>
			<div class="customer_type box_show">
				<p class="private_title">计费设置</p>
				<form action="" method="">
					<van-checkbox-group v-model="result" @change="resultChange()">
						<table class="customer_type_table">
							<tbody>
								<tr class="clearfix" v-for="(item,key) in cardList"> 
									<td>
										<van-checkbox :name="item.id" shape="square">{{item.Cardname}}</van-checkbox>
									</td>
									<td v-if="item.Cardtype == 10">
										<span class="fontSize14">期限卡不计费</span>
									</td>
									<td v-else-if="item.Cardtype == 20">
										<span class="fontSize14">计费</span>
										<span><input type="text" oninput = "value=value.replace(/[^\d]/g,'')" class="width50" v-model="inputList[key]" @input="handleInput($event,key)"></span>
										<span class="fontSize14">次</span>
									</td>
									<td v-else-if="item.Cardtype == 30">
										<span class="fontSize14">计费</span>
										<span><input type="text" oninput = "value=value.replace(/[^\d]/g,'')" class="width50" v-model="inputList[key]" @input="handleInput($event,key)"></span>
										<span class="fontSize14">元</span>
									</td>
								</tr>
							</tbody>
						</table>
					</van-checkbox-group>
				</form>
			</div>
			<div class="customer_type box_show timeType">
				<p class="private_title">课程时间</p>
				<form action="" method="">
					<ul class="sjpk">
						<li class="clearfix">
							<div class="private_left">
								课程日期
							</div>
							<div class="private_right">
								<span @click="startTimeShow = true">
									<input disabled type="text" class="width100" id="startTime" 
									:placeholder="startTimeValue ? startTimeValue : '开始日期'">
								</span>
								<span><img src="images/addtime.png"></span>
								至
								<span @click="endTimeClick()"><input disabled type="text" class="width100" id="endTime" :placeholder="endTimeValue ? endTimeValue : '结束日期'"></span>
								<span><img src="images/addtime.png"></span>
							</div>
							
						</li>
						<li class="clearfix">
							<div class="private_left">
								<span>星期一</span>
								<span><img src="images/reduce.png" @click="delWeek1Time()"></span>
								<span><img src="images/addNumber.png" data-week="1" @click="addWeek1Time()"></span>
							</div>
							<div class="private_right">
								<div v-for="(item,key) in Week1">
									<span @click="week1StartTimeClick(key,item)">
										<input type="text" disabled class="width2" id="age2" name="w1-start[0]" 
										:placeholder="item.sTime ? item.sTime : '开始时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
									<span @click="week1EtartTimeClick(key,item)">
										<input type="text" disabled class="width2 sss" id="age2" name="w1-end[0]" 
										:placeholder="item.eTime ? item.eTime : '结束时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
								</div>
							</div>
						</li>
						<li class="clearfix">
							<div class="private_left">
								<span>星期二</span>
								<span><img src="images/reduce.png" @click="delWeek2Time()"></span>
								<span><img src="images/addNumber.png" data-week="2" @click="addWeek2Time()"></span>
							</div>
							<div class="private_right">
								<div v-for="(item,key) in Week2">
									<span @click="week2StartTimeClick(key,item)">
										<input type="text" disabled class="width2" id="age2" name="w1-start[0]" 
										:placeholder="item.sTime ? item.sTime : '开始时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
									<span @click="week2EtartTimeClick(key,item)">
										<input type="text" disabled class="width2 sss" id="age2" name="w1-end[0]" 
										:placeholder="item.eTime ? item.eTime : '结束时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
								</div>
							</div>
						</li>
						<li class="clearfix">
							<div class="private_left">
								<span>星期三</span>
								<span><img src="images/reduce.png" @click="delWeek3Time()"></span>
								<span><img src="images/addNumber.png" @click="addWeek3Time()"></span>
							</div>
							<div class="private_right">
								<div v-for="(item,key) in Week3">
									<span @click="week3StartTimeClick(key,item)">
										<input type="text" disabled class="width2" id="age2" name="w1-start[0]" 
										:placeholder="item.sTime ? item.sTime : '开始时间'" 
										@click="week3StartTimeClick(key,item)"></span>
									<span><img src="images/addtime.png"></span>
									<span @click="week3EtartTimeClick(key,item)">
										<input type="text" disabled class="width2 sss" id="age2" name="w1-end[0]" 
										:placeholder="item.eTime ? item.eTime : '结束时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
								</div>
							</div>
						</li>
						<li class="clearfix">
							<div class="private_left">
								<span>星期四</span>
								<span><img src="images/reduce.png" @click="delWeek4Time()"></span>
								<span><img src="images/addNumber.png" @click="addWeek4Time()"></span>
							</div>
							<div class="private_right">
								<div v-for="(item,key) in Week4">
									<span @click="week4StartTimeClick(key,item)">
										<input type="text" disabled class="width2" id="age2" name="w1-start[0]" 
										:placeholder="item.sTime ? item.sTime : '开始时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
									<span @click="week4EtartTimeClick(key,item)"><input type="text" disabled class="width2 sss" id="age2" name="w1-end[0]" 
										:placeholder="item.eTime ? item.eTime : '结束时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
								</div>
							</div>
						</li>
						<li class="clearfix">
							<div class="private_left">
								<span>星期五</span>
								<span><img src="images/reduce.png" @click="delWeek5Time()"></span>
								<span><img src="images/addNumber.png" @click="addWeek5Time()"></span>
							</div>
							<div class="private_right">
								<div v-for="(item,key) in Week5">
									<span @click="week5StartTimeClick(key,item)">
										<input type="text" disabled class="width2" id="age2" name="w1-start[0]" 
										:placeholder="item.sTime ? item.sTime : '开始时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
									<span @click="week5EtartTimeClick(key,item)">
										<input type="text" disabled class="width2 sss" id="age2" name="w1-end[0]" 
										:placeholder="item.eTime ? item.eTime : '结束时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
								</div>
							</div>
						</li>
						<li class="clearfix">
							<div class="private_left">
								<span>星期六</span>
								<span><img src="images/reduce.png" @click="delWeek6Time()"></span>
								<span><img src="images/addNumber.png" @click="addWeek6Time()"></span>
							</div>
							<div class="private_right">
								<div v-for="(item,key) in Week6">
									<span @click="week6StartTimeClick(key,item)">
										<input type="text" disabled class="width2" id="age2" name="w1-start[0]" 
										:placeholder="item.sTime ? item.sTime : '开始时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
									<span @click="week6EtartTimeClick(key,item)">
										<input type="text" disabled class="width2 sss" id="age2" name="w1-end[0]" 
										:placeholder="item.eTime ? item.eTime : '结束时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
								</div>
							</div>
						</li>
						<li class="clearfix">
							<div class="private_left">
								<span>星期日</span>
								<span><img src="images/reduce.png" @click="delWeek7Time()"></span>
								<span><img src="images/addNumber.png" @click="addWeek7Time()"></span>
							</div>
							<div class="private_right">
								<div v-for="(item,key) in Week7">
									<span @click="week7StartTimeClick(key,item)">
										<input type="text" disabled class="width2" id="age2" name="w1-start[0]" 
										:placeholder="item.sTime ? item.sTime : '开始时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
									<span @click="week7EtartTimeClick(key,item)">
										<input type="text" disabled class="width2 sss" id="age2" name="w1-end[0]" 
										:placeholder="item.eTime ? item.eTime : '结束时间'" 
										></span>
									<span><img src="images/addtime.png"></span>
								</div>
							</div>
						</li>
					</ul>
				</form>
				<!-- 开始日期 -->
				<van-popup v-model="startTimeShow" position="bottom">
					<van-datetime-picker
					v-model="startTime"
					type="date"
					@confirm="sureStartTime"
					@cancel="startTimeShow = false"
					/>
				</van-popup>
				<!-- 结束日期 -->
				<van-popup v-model="endTimeShow" position="bottom">
					<van-datetime-picker
					v-model="endTime"
					type="date"
					:min-date="val"
					@confirm="sureEndTime"
					@cancel="endTimeShow = false"
					/>
				</van-popup>
				<!-- 周一 -->
				<template v-for="(item,key) in Week1">
					<van-popup v-model="item.sShow" position="bottom">
						<van-datetime-picker
						v-model="item.sTime"
						type="time"
						@confirm="confirmWeek1SStime"
						@cancel="item.sShow = false"
						/>
					</van-popup>
					<van-popup v-model="item.eShow" position="bottom">
						<van-datetime-picker
						v-model="item.eTime"
						type="time"
						:min-hour="Number((String(item.sTime).split(':'))[0])"
						@confirm="confirmWeek1EStime"
						@cancel="item.eShow = false"
						/>
					</van-popup>
				</template>
				<!-- 周二 -->
				<template v-for="(item,key) in Week2">
					<van-popup v-model="item.sShow" position="bottom">
						<van-datetime-picker
						v-model="item.sTime"
						type="time"
						@confirm="confirmWeek2SStime"
						@cancel="item.sShow = false"
						/>
					</van-popup>
					<van-popup v-model="item.eShow" position="bottom">
						<van-datetime-picker
						v-model="item.eTime"
						type="time"
						:min-hour="Number((String(item.sTime).split(':'))[0])"
						@confirm="confirmWeek2EStime"
						@cancel="item.eShow = false"
						/>
					</van-popup>
				</template>
				<!-- 周三 -->
				<template v-for="(item,key) in Week3">
					<van-popup v-model="item.sShow" position="bottom">
						<van-datetime-picker
						v-model="item.sTime"
						type="time"
						@confirm="confirmWeek3SStime"
						@cancel="item.sShow = false"
						/>
					</van-popup>
					<van-popup v-model="item.eShow" position="bottom">
						<van-datetime-picker
						v-model="item.eTime"
						type="time"
						:min-hour="Number((String(item.sTime).split(':'))[0])"
						@confirm="confirmWeek3EStime"
						@cancel="item.eShow = false"
						/>
					</van-popup>
				</template>
				<!-- 周四 -->
				<template v-for="(item,key) in Week4">
					<van-popup v-model="item.sShow" position="bottom">
						<van-datetime-picker
						v-model="item.sTime"
						type="time"
						@confirm="confirmWeek4SStime"
						@cancel="item.sShow = false"
						/>
					</van-popup>
					<van-popup v-model="item.eShow" position="bottom">
						<van-datetime-picker
						v-model="item.eTime"
						type="time"
						:min-hour="Number((String(item.sTime).split(':'))[0])"
						@confirm="confirmWeek4EStime"
						@cancel="item.eShow = false"
						/>
					</van-popup>
				</template>
				<!-- 周五 -->
				<template v-for="(item,key) in Week5">
					<van-popup v-model="item.sShow" position="bottom">
						<van-datetime-picker
						v-model="item.sTime"
						type="time"
						@confirm="confirmWeek5SStime"
						@cancel="item.sShow = false"
						/>
					</van-popup>
					<van-popup v-model="item.eShow" position="bottom">
						<van-datetime-picker
						v-model="item.eTime"
						type="time"
						:min-hour="Number((String(item.sTime).split(':'))[0])"
						@confirm="confirmWeek5EStime"
						@cancel="item.eShow = false"
						/>
					</van-popup>
				</template>
				<!-- 周六 -->
				<template v-for="(item,key) in Week6">
					<van-popup v-model="item.sShow" position="bottom">
						<van-datetime-picker
						v-model="item.sTime"
						type="time"
						@confirm="confirmWeek6SStime"
						@cancel="item.sShow = false"
						/>
					</van-popup>
					<van-popup v-model="item.eShow" position="bottom">
						<van-datetime-picker
						v-model="item.eTime"
						type="time"
						:min-hour="Number((String(item.sTime).split(':'))[0])"
						@confirm="confirmWeek6EStime"
						@cancel="item.eShow = false"
						/>
					</van-popup>
				</template>
				<!-- 周日 -->
				<template v-for="(item,key) in Week7">
					<van-popup v-model="item.sShow" position="bottom">
						<van-datetime-picker
						v-model="item.sTime"
						type="time"
						@confirm="confirmWeek7SStime"
						@cancel="item.sShow = false"
						/>
					</van-popup>
					<van-popup v-model="item.eShow" position="bottom">
						<van-datetime-picker
						v-model="item.eTime"
						type="time"
						:min-hour="Number((String(item.sTime).split(':'))[0])"
						@confirm="confirmWeek7EStime"
						@cancel="item.eShow = false"
						/>
					</van-popup>
				</template>
				<div class="sub_btn_div">
					<input type="submit" name="" value="" class="sub_btn" readonly="readonly" @click="submit()">
				</div>
				<div class="technology">由馆家提供技术支持</div>
				<input type="text" class="width2" id="age33" placeholder="结束时间" style="display:none;">
			</div>
		</template>
	</div>
	
</body>
<script>
var app = new Vue({
	el: '#app',
	data: {
		//id
		id:null,
		//课程显示
		classShow:false,
		//课程列表数据
		classList:null,
		//课程选中数据
		classVal:null,
		//教练显示
		jlShow:false,
		//教练列表
		jlList:null,
		//教练选中数据
		jlVal:null,
		//场地显示
		siteShow:false,
		//场地列表
		siteList:null,
		//场地选中
		siteVal:null,
		//会员卡列表
		cardList:null,
		//选中的会员卡
		result:[],
		//input
		inputList:[],
		//开始日期弹出成
		startTimeShow:false,
		//开始日期、
		startTime:new Date(),
		//确定开始日期
		startTimeValue:null,
		//结束日期弹出层
		endTimeShow:false,
		//结束日期
		endTime:new Date(),
		//确认结束日期
		endTimeValue:null,
		//结束日期最小开始日期
		val:null,
		//星期一时间数组
		Week1:[{
			sTime:null,
			eTime:null,
			sShow:false,
			eShow:false
		}],
		//周一key
		week1Key:null,
		//周二数组
		Week2:[{
			sTime:null,
			eTime:null,
			sShow:false,
			eShow:false
		}],
		//周二key
		week2Key:null,
		// 周三****************
		// 周三数组
		Week3:[{
			sTime:null,
			eTime:null,
			sShow:false,
			eShow:false
		}],
		// 周三key
		week3Key:null,
		// 周四***************
		// 周四数组
		Week4:[{
			sTime:null,
			eTime:null,
			sShow:false,
			eShow:false
		}],
		// 周四key
		week4Key:null,
		// 周五*****************
		// 周五数组
		Week5:[{
			sTime:null,
			eTime:null,
			sShow:false,
			eShow:false
		}],
		// 周五key
		week5Key:null,
		// 周六******************
		// 周六数组
		Week6:[{
			sTime:null,
			eTime:null,
			sShow:false,
			eShow:false
		}],
		// 周六key
		week6Key:null,
		// 周日****************
		// 周日数组
		Week7:[{
			sTime:null,
			eTime:null,
			sShow:false,
			eShow:false
		}],
		// 周日key
		week7Key:null,
		//是否预约
		IsBespeak:0,
		//是否签到
		IsSign:0
	},
	created() {
		//获取路由参数
		let id = getUrlQueryString('id');
		this.id = id;
		if (id) {
			//编辑
			axios.get(`/mobileapi/boss/curriculum_plan.php?act=editCurriculumPlan&ctype=0&id=${id}`).then(res=>{
				if (res.data.code == 200) {
					//课程列表
					let type = res.data.data.type;
					this.classList = type;
					//课程选中对象
					type.forEach(item=>{
						if (item.id == res.data.data.Tid) {
							this.classVal = item;
						}
					});
					//教练列表
					let staff = res.data.data.staff;
					this.jlList = staff;
					//选中教练
					staff.forEach(item=>{
						if (item.id == res.data.data.Coach) {
							this.jlVal = item;
						}
					});
					//场地列表
					let spaceList = res.data.data.space;
					this.siteList = spaceList;
					//选中场地
					spaceList.forEach(item=>{
						if (item.id == res.data.data.Space) {
							this.siteVal = item;
							console.log(item);
						}
					});
					//是否预约
					this.IsBespeak = res.data.data.IsBespeak;
					//是否签到
					this.IsSign = res.data.data.IsSign;
					//卡列表
					this.cardList = res.data.data.cardset;
					res.data.data.cardset.forEach(item => {
						this.inputList.push(item.Consumption);
					});
					let cardCheck = [];
					// 选中的卡
					res.data.data.cardset_check.forEach(item=>{
						cardCheck.push(item.id);
					});
					this.result = cardCheck;
					//日期回显
					this.startTimeValue =res.data.data.Sdate;
					let sdate = new Date(res.data.data.Sdate);
					this.startTime = sdate;
					this.endTimeValue =res.data.data.Edate;
					let edate = new Date(res.data.data.Edate);
					this.endTime = edate;
					this.val = sdate;
					// 时间回显
					this.Week1 = getWeek(res.data.data.Week_1);
					this.Week2 = getWeek(res.data.data.Week_2);
					this.Week3 = getWeek(res.data.data.Week_3);
					this.Week4 = getWeek(res.data.data.Week_4);
					this.Week5 = getWeek(res.data.data.Week_5);
					this.Week6 = getWeek(res.data.data.Week_6);
					this.Week7 = getWeek(res.data.data.Week_7);
				}else{
					vant.Toast(res.data.msg);
				}
			}).catch(err=>{
				vant.Toast('请求发送失败，请重试');
			});
		}else{
			//获取下拉框数据
			axios.get('/mobileapi/boss/curriculum_plan.php?act=addCurriculumPlan&ctype=0').then(res=>{
				if(res.data.code == 200){
					//课程列表
					this.classList = res.data.data.type;
					//教练列表
					this.jlList = res.data.data.staff;
					//场地列表
					this.siteList = res.data.data.space;
					//会员卡列表
					this.cardList = res.data.data.cardset;
					res.data.data.cardset.forEach(item => {
						this.inputList.push("0");
					});
					console.log(this.inputList);
				}else{
					vant.Toast(res.data.msg);
				}
			}).catch(err=>{
				vant.Toast('请求发送失败，请重试')
			})
		}
		
	},
	methods: {
		//课程确认
		classYes(val){
			this.classVal = val;
			this.classShow = false;
		},
		//教练确认
		jlYes(val){
			this.jlVal = val;
			this.jlShow = false;
		},
		//场地确认
		siteYes(val){
			this.siteVal = val;
			this.siteShow = false;
		},
		resultChange(){
			console.log(this.result);
		},
		//开始日期确认
		sureStartTime(val){
			this.val = val;
			this.startTimeValue = changeDate(val);
			this.startTimeShow = false;
		},
		//点击结束日期
		endTimeClick(){
			//判断是否选择开始时间
			if (this.val == null) {
				vant.Toast('请选择开始时间');
				return false;
			}else{
				this.endTimeShow = true;
			}
		},
		//结束日期确认
		sureEndTime(val){
			this.endTimeValue = changeDate(val);
			this.endTimeShow = false;
		},
		// 周一****************************
		//周一开始时间确认
		confirmWeek1SStime(val){
			this.Week1[this.week1Key].sTime = val;
			this.Week1[this.week1Key].sShow = false;
		},
		//周一结束时间确认
		confirmWeek1EStime(val){
			this.Week1[this.week1Key].eTime = val;
			this.Week1[this.week1Key].eShow = false;
		},
		//点击周一开始时间
		week1StartTimeClick(key,item){
			this.week1Key = key;
			item.sShow = true;
		},
		//点击周一结束时间
		week1EtartTimeClick(key,item){
			//判断是否选择开始时间
			if (item.sTime == null) {
				vant.Toast('请先选择开始时间');
				return false;
			}else{
				this.week1Key = key;
				item.eShow = true;
			}
		},
		//周一添加时间端按钮
		addWeek1Time(){
			let obj ={
				sTime:null,
				eTime:null,
				sShow:false,
				eShow:false
			};
			this.Week1.push(obj);
		},
		//周一减少时间端按钮
		delWeek1Time(){
			let arr = this.Week1;
			//判断是否是最后一条
			if (arr.length<=1) {
				return false;
			}else{
				arr.pop();
				this.Week1 = arr;
			}
		},
		// 周二****************************
		//周二开始时间确认
		confirmWeek2SStime(val){
			this.Week2[this.week2Key].sTime = val;
			this.Week2[this.week2Key].sShow = false;
		},
		//周二结束时间确认
		confirmWeek2EStime(val){
			this.Week2[this.week2Key].eTime = val;
			this.Week2[this.week2Key].eShow = false;
		},
		//点击周二开始时间
		week2StartTimeClick(key,item){
			this.week2Key = key;
			item.sShow = true;
		},
		//点击周二结束时间
		week2EtartTimeClick(key,item){
			//判断是否选择开始时间
			if (item.sTime == null) {
				vant.Toast('请先选择开始时间');
				return false;
			}else{
				this.week2Key = key;
				item.eShow = true;
			}
		},
		//周二添加时间端按钮
		addWeek2Time(){
			let obj ={
				sTime:null,
				eTime:null,
				sShow:false,
				eShow:false
			};
			this.Week2.push(obj);
		},
		//周二减少时间端按钮
		delWeek2Time(){
			let arr = this.Week2;
			//判断是否是最后一条
			if (arr.length<=1) {
				return false;
			}else{
				arr.pop();
				this.Week2 = arr;
			}
		},
		// 周三*********************************
		//周三开始时间确认
		confirmWeek3SStime(val){
			this.Week3[this.week3Key].sTime = val;
			this.Week3[this.week3Key].sShow = false;
		},
		//周三结束时间确认
		confirmWeek3EStime(val){
			this.Week3[this.week3Key].eTime = val;
			this.Week3[this.week3Key].eShow = false;
		},
		//点击周三开始时间
		week3StartTimeClick(key,item){
			this.week3Key = key;
			item.sShow = true;
		},
		//点击周三结束时间
		week3EtartTimeClick(key,item){
			//判断是否选择开始时间
			if (item.sTime == null) {
				vant.Toast('请先选择开始时间');
				return false;
			}else{
				this.week3Key = key;
				item.eShow = true;
			}
		},
		//周三添加时间端按钮
		addWeek3Time(){
			let obj ={
				sTime:null,
				eTime:null,
				sShow:false,
				eShow:false
			};
			this.Week3.push(obj);
		},
		//周三减少时间端按钮
		delWeek3Time(){
			let arr = this.Week3;
			//判断是否是最后一条
			if (arr.length<=1) {
				return false;
			}else{
				arr.pop();
				this.Week3 = arr;
			}
		},
		// 周四**********************************
		//周四开始时间确认
		confirmWeek4SStime(val){
			this.Week4[this.week4Key].sTime = val;
			this.Week4[this.week4Key].sShow = false;
		},
		//周四结束时间确认
		confirmWeek4EStime(val){
			this.Week4[this.week4Key].eTime = val;
			this.Week4[this.week4Key].eShow = false;
		},
		//点击周四开始时间
		week4StartTimeClick(key,item){
			this.week4Key = key;
			item.sShow = true;
		},
		//点击周四结束时间
		week4EtartTimeClick(key,item){
			//判断是否选择开始时间
			if (item.sTime == null) {
				vant.Toast('请先选择开始时间');
				return false;
			}else{
				this.week4Key = key;
				item.eShow = true;
			}
		},
		//周四添加时间端按钮
		addWeek4Time(){
			let obj ={
				sTime:null,
				eTime:null,
				sShow:false,
				eShow:false
			};
			this.Week4.push(obj);
		},
		//周四减少时间端按钮
		delWeek4Time(){
			let arr = this.Week4;
			//判断是否是最后一条
			if (arr.length<=1) {
				return false;
			}else{
				arr.pop();
				this.Week4 = arr;
			}
		},
		// 周五***********************************
		//周五开始时间确认
		confirmWeek5SStime(val){
			this.Week5[this.week5Key].sTime = val;
			this.Week5[this.week5Key].sShow = false;
		},
		//周五结束时间确认
		confirmWeek5EStime(val){
			this.Week5[this.week5Key].eTime = val;
			this.Week5[this.week5Key].eShow = false;
		},
		//点击周五开始时间
		week5StartTimeClick(key,item){
			this.week5Key = key;
			item.sShow = true;
		},
		//点击周五结束时间
		week5EtartTimeClick(key,item){
			//判断是否选择开始时间
			if (item.sTime == null) {
				vant.Toast('请先选择开始时间');
				return false;
			}else{
				this.week5Key = key;
				item.eShow = true;
			}
		},
		//周五添加时间端按钮
		addWeek5Time(){
			let obj ={
				sTime:null,
				eTime:null,
				sShow:false,
				eShow:false
			};
			this.Week5.push(obj);
		},
		//周五减少时间端按钮
		delWeek5Time(){
			let arr = this.Week5;
			//判断是否是最后一条
			if (arr.length<=1) {
				return false;
			}else{
				arr.pop();
				this.Week5 = arr;
			}
		},
		// 周六***********************************
		//周六开始时间确认
		confirmWeek6SStime(val){
			this.Week6[this.week6Key].sTime = val;
			this.Week6[this.week6Key].sShow = false;
		},
		//周六结束时间确认
		confirmWeek6EStime(val){
			this.Week6[this.week6Key].eTime = val;
			this.Week6[this.week6Key].eShow = false;
		},
		//点击周六开始时间
		week6StartTimeClick(key,item){
			this.week6Key = key;
			item.sShow = true;
		},
		//点击周六结束时间
		week6EtartTimeClick(key,item){
			//判断是否选择开始时间
			if (item.sTime == null) {
				vant.Toast('请先选择开始时间');
				return false;
			}else{
				this.week6Key = key;
				item.eShow = true;
			}
		},
		//周六添加时间端按钮
		addWeek6Time(){
			let obj ={
				sTime:null,
				eTime:null,
				sShow:false,
				eShow:false
			};
			this.Week6.push(obj);
		},
		//周六减少时间端按钮
		delWeek6Time(){
			let arr = this.Week6;
			//判断是否是最后一条
			if (arr.length<=1) {
				return false;
			}else{
				arr.pop();
				this.Week6 = arr;
			}
		},
		// 周日***********************************
		//周日开始时间确认
		confirmWeek7SStime(val){
			this.Week7[this.week7Key].sTime = val;
			this.Week7[this.week7Key].sShow = false;
		},
		//周六日结束时间确认
		confirmWeek7EStime(val){
			this.Week7[this.week7Key].eTime = val;
			this.Week7[this.week7Key].eShow = false;
		},
		//点击周日开始时间
		week7StartTimeClick(key,item){
			this.week7Key = key;
			item.sShow = true;
		},
		//点击周日结束时间
		week7EtartTimeClick(key,item){
			//判断是否选择开始时间
			if (item.sTime == null) {
				vant.Toast('请先选择开始时间');
				return false;
			}else{
				this.week7Key = key;
				item.eShow = true;
			}
		},
		//周日添加时间端按钮
		addWeek7Time(){
			let obj ={
				sTime:null,
				eTime:null,
				sShow:false,
				eShow:false
			};
			this.Week7.push(obj);
		},
		//周日减少时间端按钮
		delWeek7Time(){
			let arr = this.Week7;
			//判断是否是最后一条
			if (arr.length<=1) {
				return false;
			}else{
				arr.pop();
				this.Week7 = arr;
			}
		},
		//选择是否预约
		bespeakClick(val){
			this.IsBespeak = val;
		},
		// 选择是否会员请按到
		signClick(val){
			this.IsSign = val;
		},
		//输入框验证
		handleInput(e,key){
			this.inputList[key] = e.target.value.replace(/[^\d]/g,'');
		},
		//提交按钮
		submit(){
			//判断是否
			if (this.classVal == null || this.classVal == '') {
				vant.Toast('请选择课程名称');
				return false;
			}
			if (this.jlVal == null || this.jlVal == '') {
				vant.Toast('请选择教练');
				return false;
			}
			if (this.siteVal == null || this.siteVal == '') {
				vant.Toast('请选择场地');
				return false;
			}
			//发送会员卡的整合数据
			let CardCharge = [];
			let arr = [];
			//整合计费数据
			this.cardList.forEach((item,key)=>{
				let obj = {
					Csid:item.id,
					Cardname:item.Cardname,
					Cardclass:item.Cardclass,
					Cardtype:item.Cardtype,
					Consumption:this.inputList[key]
				};
				arr.push(obj);
			});
			this.result.forEach(item=>{
				arr.forEach(items=>{
					if (item == items.Csid) {
						CardCharge.push(items);
					}
				})
			});
			//判断是否选择了卡
			if (CardCharge.length<1) {
				vant.Toast('至少需要选中一种类型的卡');
				return false;
			}
			//判断选中的卡计费设置是否填写
			CardCharge.forEach(item=>{
				if (item.Consumption == null || item.Consumption == "") {
					vant.Toast('请为选中的卡填写计费规则');
					return false;
				}
			})
			// 判断课程日期是否选择
			if (this.startTimeValue == null || this.startTimeValue == '') {
				vant.Toast('请选择课程开始日期');
				return false;
			}
			if (this.endTimeValue == null || this.endTimeValue == '') {
				vant.Toast('请选择课程结束日期');
				return false;
			}
			//判断是否至少添加了个时间端
			let week1 = false;
			let Week_1 = [];
			this.Week1.forEach(item=>{
				console.log(item);
				if (item.sTime == null || item.eTime == null) {
					week1 = false;
				}else{
					week1 = true;
					let obj = {
						stime:item.sTime,
						etime:item.eTime
					};
					Week_1.push(obj);
				};
			});
			let week2 = false;
			let Week_2 = [];
			this.Week2.forEach(item=>{
				if (item.sTime == null || item.eTime == null) {
					week2 = false;
				}else{
					week2 = true;
					let obj = {
						stime:item.sTime,
						etime:item.eTime
					};
					Week_2.push(obj);
				}
			});
			let week3 = false;
			let Week_3 = [];
			this.Week3.forEach(item=>{
				if (item.sTime == null || item.eTime == null) {
					week3 = false;
				}else{
					week3 = true;
					let obj = {
						stime:item.sTime,
						etime:item.eTime
					};
					Week_3.push(obj);
				}
			});
			let week4 = false;
			let Week_4 = [];
			this.Week4.forEach(item=>{
				if (item.sTime == null || item.eTime == null) {
					week4 = false;
				}else{
					week4 = true;
					let obj = {
						stime:item.sTime,
						etime:item.eTime
					};
					Week_4.push(obj);
				}
			});
			let week5 = false;
			let Week_5 = [];
			this.Week5.forEach(item=>{
				if (item.sTime == null || item.eTime == null) {
					week5 = false;
				}else{
					week5 = true;
					let obj = {
						stime:item.sTime,
						etime:item.eTime
					};
					Week_5.push(obj);
				}
			});
			let week6 = false;
			let Week_6 = [];
			this.Week6.forEach(item=>{
				if (item.sTime == null || item.eTime == null) {
					week6 = false;
				}else{
					week6 = true;
					let obj = {
						stime:item.sTime,
						etime:item.eTime
					};
					Week_6.push(obj);
				}
			});
			let week7 = false;
			let Week_7 = [];
			this.Week7.forEach(item=>{
				if (item.sTime == null || item.eTime == null) {
					week7 = false;
				}else{
					week7 = true;
					let obj = {
						stime:item.sTime,
						etime:item.eTime
					};
					Week_7.push(obj);
				}
			});
			if (!(week1 || week2 || week3 || week4 || week5 || week6 || week7)) {
				vant.Toast('请至少在某一天中添加一个完整的时间段');
				return false;
			};
			
			//判断是修改还是添加
			if (this.id) {
				//是编辑
				//整合数据
				let from = JSON.stringify({
					id:this.id,
					Tid:this.classVal.id,
					Space:this.siteVal.id,
					Coach:this.jlVal.id,
					Ctype:0,
					IsBespeak:this.IsBespeak,
					IsSign:this.IsSign,
					Sdate:this.startTimeValue,
					Edate:this.endTimeValue,
					CardCharge:CardCharge,
					Week_1,
					Week_2,
					Week_3,
					Week_4,
					Week_5,
					Week_6,
					Week_7
				});
				let sign = md5(from);
				let params = {
					from,
					sign
				};
				axios.post('/mobileapi/boss/curriculum_plan.php?act=editCurriculumPlanGo',Qs.stringify(params)).then(res=>{
					if (res.data.code == 200) {
						vant.Toast('团课排课修改成功');
						setTimeout(()=>{
							// history.go(-1);
							location.href = "groupClassList.html";
						},1500);
					}else{
						vant.Toast(res.data.msg);
					}
				}).catch(err=>{
					vant.Toast('请求发送失败，请重试');
				});
			}else{
				//是添加
				//整合数据
				let from = JSON.stringify({
					Tid:this.classVal.id,
					Space:this.siteVal.id,
					Coach:this.jlVal.id,
					Ctype:0,
					IsBespeak:this.IsBespeak,
					IsSign:this.IsSign,
					Sdate:this.startTimeValue,
					Edate:this.endTimeValue,
					CardCharge:CardCharge,
					Week_1,
					Week_2,
					Week_3,
					Week_4,
					Week_5,
					Week_6,
					Week_7
				});
				let sign = md5(from);
				let params = {
					from,
					sign
				};
				axios.post('/mobileapi/boss/curriculum_plan.php?act=addCurriculumPlanGo',Qs.stringify(params)).then(res=>{
					if (res.data.code == 200) {
						vant.Toast('团课排课添加成功');
						setTimeout(()=>{
							// history.go(-1);
							location.href = "groupClassList.html";
						},1500);
					}else{
						vant.Toast(res.data.msg);
					}
				}).catch(err=>{
					vant.Toast('请求发送失败，请重试');
				});
			}
			
		}
	}
})
</script>
</html>